package com.ktjy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktjy.dto.DictTypeDTO;
import com.ktjy.mapper.SysDictTypeMapper;
import com.ktjy.pojo.SysDictType;
import com.ktjy.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-08-17
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService {
    @Autowired
    SysDictTypeMapper sysDictTypeMapper;

    @Override
    public IPage<SysDictType> findPage(DictTypeDTO dictTypeDTO, Integer pageNo, Integer pageSize) {
        //构造分页条件
        Page page=new Page(pageNo,pageSize);
        //构造查询条件
        QueryWrapper qw=new QueryWrapper();
        if(dictTypeDTO.getDictName()!=null && !dictTypeDTO.getDictName().isEmpty()){
            qw.like("dict_name",dictTypeDTO.getDictName());
        }
        if(dictTypeDTO.getDictType()!=null && !dictTypeDTO.getDictType().isEmpty()){
            qw.eq("dict_type",dictTypeDTO.getDictType());
        }
        if(dictTypeDTO.getStatus()!=null && !dictTypeDTO.getStatus().isEmpty()){
            qw.eq("status",dictTypeDTO.getStatus());
        }
        if(dictTypeDTO.getBeginTime()!=null && !dictTypeDTO.getBeginTime().isEmpty()){
            qw.ge("create_time",dictTypeDTO.getBeginTime()+" 00:00:00");
        }
        if(dictTypeDTO.getEndTime()!=null && !dictTypeDTO.getEndTime().isEmpty()){
            qw.le("create_time",dictTypeDTO.getEndTime()+" 23:59:59");
        }
        return sysDictTypeMapper.selectPage(page,qw);
    }
}
